package com.coolrui.domain.user.service;

import com.coolrui.common.system.ApiList;
import com.coolrui.domain.user.entity.UserAccount;
import com.coolrui.domain.user.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserDomainService {
    @Autowired
    private UserRepository userRepository;

    public UserAccount getUser(Long userId) {
        return userRepository.getUser(userId);
    }

    public List<UserAccount> getUserList(Integer page, Integer pageSize) {
        return userRepository.getUserList(page, pageSize);
    }

    public ApiList<UserAccount> getUserList(Long cityId, Integer page, Integer pageSize) {
        return userRepository.getUserList(cityId, page, pageSize);
    }

    @Transactional(rollbackFor = Exception.class)
    public int createUser(UserAccount user) {
        return userRepository.createUser(user);
    }
}